package rule18;

import java.util.Collection;
import java.util.Set;

/**
 * 脏活累活都是SetWrapper来做了
 * 这个类的职责就清晰了
 * @author ChangLiang
 * @date 2020/3/17
 */
public class HashSetCounterV3 extends SetWrapper{

    private int count;

    public HashSetCounterV3(Set set) {
        super(set);
    }

    @Override
    public boolean add(Object object) {
        count++;
        return super.add(object);
    }

    @Override
    public boolean addAll(Collection collection) {
        count += collection.size();
        return super.addAll(collection);
    }

    public int getCount() {
        return count;
    }

}
